/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package aptech.semester.code.data;

import aptech.semester.code.conn.MyLib;
import aptech.semester.code.entity.BankEntity;
import aptech.semester.code.entity.EducationEntity;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.List;

/**
 *
 * @author vi
 */
public class EducationList {
    private String QUERY_ALL_EDUCATION = "SELECT * FROM EDUCATION_LEVEL";
    
    public List<EducationEntity> getAllEducationLevel() {
        List<EducationEntity> listEducation = new ArrayList<>();
        
        try {          
            Connection cn = MyLib.getCN();
            if(cn != null) {
                Statement st = cn.createStatement();
                 ResultSet rs = st.executeQuery(QUERY_ALL_EDUCATION);
                 
                while(rs.next()) {
                    EducationEntity education = new EducationEntity();
                    education.setEducationId(rs.getInt("ID"));
                    education.setEducationName(rs.getString("EDUCATION_LEVEL_NAME"));                    
                    education.setDescription(rs.getString("DESCRIPTION"));
                     
                    listEducation.add(education);
                }
                rs.close();
                cn.close();
            }           
        } catch (Exception e) {
            e.printStackTrace();
        } 
        return listEducation;
    }
}
